//
//  KFBox.m
//  cc
//
//  Created by ZLQ on 2016/10/24.
//  Copyright © 2016年 hbyj. All rights reserved.
//

#import "KFBox.h"
@implementation KFBox

+ (void)setBoxAddTitle:(NSString *)title addDtitle:(NSString *)Dtitle addController:(id)VC num:(int)num
{

    UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:Dtitle preferredStyle:UIAlertControllerStyleAlert];
    if (num != 2) {
        UIAlertAction *action = [UIAlertAction actionWithTitle:@"我知道了" style:UIAlertActionStyleCancel handler:nil];
        [alert addAction:action];
    }else
    {
        UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            //NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
            //[center postNotificationName:@"BOX" object:self];
            [VC popViewControllerAnimated:YES];
        }];
        UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil];
        [alert addAction:action1];
        [alert addAction:action2];
    }

    [VC presentViewController:alert animated:YES completion:nil];

}
//去除 空格
+ (NSString *)trim:(NSString *)_str{
    return [_str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
}
//去除特殊符号
//NSCharacterSet *set = [NSCharacterSet characterSetWithCharactersInString:@"@／：；（）¥「」＂、[]{}#%-*+=_\\|~＜＞$€^•'@#$%^&*()_+'\""];
//NSString *trimmedString = [string stringByTrimmingCharactersInSet:set];

+ (BOOL)isMobileNumber:(NSString *)mobileNum {
    
    //    电信号段:133/153/180/181/189/177
    //    联通号段:130/131/132/155/156/185/186/145/176
    //    移动号段:134/135/136/137/138/139/150/151/152/157/158/159/182/183/184/187/188/147/178
    //    虚拟运营商:170
    
    NSString *MOBILE = @"^1(3[0-9]|4[57]|5[0-35-9]|8[0-9]|7[06-8])\\d{8}$";
    
    NSPredicate *regextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", MOBILE];
    
    return [regextestmobile evaluateWithObject:mobileNum];
}

@end
